import { Encoding } from './encoding';


export class FontTable extends Array {
  _mixedEncodings: boolean | null = null;

  public get MixedEncodings(): boolean {

    if (this._mixedEncodings != null)
      return this._mixedEncodings;

    let currentEncoding: Encoding = null;
    this._mixedEncodings = false;

    for (let font of this) {
      if (font.Encoding != null && currentEncoding == null)
        currentEncoding = font.Encoding;
      else if (currentEncoding != null && font.Encoding != null && currentEncoding.codePage != font.Encoding.codePage) {
        this._mixedEncodings = true;
        break;
      }
    }
    return this._mixedEncodings;
  }

  clear() {
    this.splice(0,this.length);
  }
}